package cn.stylefeng.guns.modular.business.frequency.cmcompanyorder.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import cn.stylefeng.guns.modular.business.frequency.cmcompanyorder.service.CmCompanyOrderService;
import cn.stylefeng.guns.modular.business.frequency.cmcompanyorder.model.param.CmCompanyOrderParam;

import javax.annotation.Resource;

/**
 * 通讯录联系人表 控制器
 *
 * @author: yujie
 * @date: 2023/05/09 17:17
 */
@RestController
public class CmCompanyOrderController {

    @Resource
    private CmCompanyOrderService cmCompanyOrderService;

    /**
     * 分页查询通讯录联系人表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @GetMapping("/cmCompanyOrder/page")
    @BusinessLog(title = "通讯录联系人表_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(CmCompanyOrderParam cmCompanyOrderParam) {
        return new SuccessResponseData(cmCompanyOrderService.page(cmCompanyOrderParam));
    }

    /**
     * 获取全部通讯录联系人表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @GetMapping("/cmCompanyOrder/list")
    @BusinessLog(title = "通讯录联系人表_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(CmCompanyOrderParam cmCompanyOrderParam) {
        return new SuccessResponseData(cmCompanyOrderService.list(cmCompanyOrderParam));
    }

    /**
     * 查看详情通讯录联系人表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @GetMapping("/cmCompanyOrder/detail")
    @BusinessLog(title = "通讯录联系人表_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(CmCompanyOrderParam.detail.class) CmCompanyOrderParam cmCompanyOrderParam) {
        return new SuccessResponseData(cmCompanyOrderService.detail(cmCompanyOrderParam));
    }

    /**
     * 添加通讯录联系人表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/cmCompanyOrder/add")
    @BusinessLog(title = "通讯录联系人表_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(CmCompanyOrderParam.add.class) CmCompanyOrderParam cmCompanyOrderParam) {
        cmCompanyOrderService.add(cmCompanyOrderParam);
        return new SuccessResponseData();
    }

    /**
     * 删除通讯录联系人表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/cmCompanyOrder/delete")
    @BusinessLog(title = "通讯录联系人表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(CmCompanyOrderParam.delete.class) CmCompanyOrderParam cmCompanyOrderParam) {
        cmCompanyOrderService.delete(cmCompanyOrderParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑通讯录联系人表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/cmCompanyOrder/edit")
    @BusinessLog(title = "通讯录联系人表_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(CmCompanyOrderParam.edit.class) CmCompanyOrderParam cmCompanyOrderParam) {
        cmCompanyOrderService.edit(cmCompanyOrderParam);
        return new SuccessResponseData();
    }


}
